﻿@using Newtouch.Herp.Infrastructure.Enum
@using Newtouch.Herp.Infrastructure;
@{
    ViewBag.Title = "本部门物资查询";
    Layout = "~/Views/Shared/_Index.cshtml";
    var reportUrl = Newtouch.Core.Common.Utils.ConfigurationHelper.GetAppConfigValue("ReportUrl");
    var reportSystemCode = Newtouch.Core.Common.Utils.ConfigurationHelper.GetAppConfigValue("ReportSystemCode");
}
<style>
    #btn_search {
        float: left;
        margin-left: 25px;
        margin-right: 10px;
        width: 45px;
        font-weight: bolder;
    }

    #btn_print {
        width: 45px;
        background-color: #fff;
        color: #00a9ea;
        font-weight: bolder;
        float: left;
    }
</style>
<form id="form1">
    <div class="panel panel-default">
        <div class="panel-heading">
            筛选条件
        </div>
        <div>
            <table class="form">
                <tr>
                    <td class="formTitle">物资名称：</td>
                    <td class="formValue" style="width:120px;">
                        <input type="text" id="keyWord" class="form-control" placeholder="拼音/名称" />
                        <input type="hidden" id="productId" value="" />
                    </td>
                    <td class="formTitle">类别：</td>
                    <td class="formValue formDdlSelectorTd">
                        <select class="form-control" id="lb">
                            <option value="">全部</option>
                        </select>
                    </td>
                    <td class="formTitle">使用状态：</td>
                    <td class="formValue formDdlSelectorTd" style="width:75px;">
                        <select class="form-control" id="kzbz" name="kzbz">
                            <option value="">全部</option>
                            <option value="1">正常</option>
                            <option value="0">控制</option>
                        </select>
                    </td>
                    <td class="formTitle">物资状态：</td>
                    <td class="formValue formDdlSelectorTd" style="width:75px;">
                        @Html.DropDownList("wzzt", Enumzt.Enable.ToDescSelectList(), "全部", new { @class = "form-control" })
                    </td>
                    <td class="formTitle" style="width:180px;">
                        <input type="button" class="btn btn-primary btn-md" id="btn_search" value="查询" />
                        <input type="button" id="btn_print" class="btn btn-primary" value="打印" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
</form>
<div class="gridPanel" style="margin-top:10px">
    <table id="gridList"></table>
    <div id="gridPager" rel="form1"></div>
</div>
<script>
    var par = new Object();
    var $gridList = $("#gridList");
    $(function () {
        initialddlYPLBList();
        gridList();
    });

    //获取物资信息
    function gridList() {
        $gridList.dataGrid({
            url: "/WarehouseManage/Warehouse/GetWarehouseProducts",
            postData: $("#form1").formSerialize(),
            height: $(window).height() - document.getElementById('gridList').offsetTop - 70,
            colModel: [
                {
                    label: '控制标志', name: 'kzbz', width: 60, align: 'center',
                    formatter: function (cellvalue) { return cellvalue === "1" ? "正常" : "控制"; }
                },
                {
                    label: '物资状态', name: 'wzzt', width: 60, align: 'center',
                    formatter: function (cellvalue) { return cellvalue === "1" ? "可用" : "无效"; }
                },
                { label: '名称', name: 'wzmc', width: 180, align: 'left' },
                { label: '国家医保码', name: 'gjybdm', width: 100, align: 'left' },
                { label: '拼音', name: 'py', width: 70, align: 'left' },
                { label: '类别', name: 'lb', width: 100, align: 'left' },
                { label: '最小起订数', name: 'zxqds', width: 70, align: 'left' },
                {
                    label: '零售价', name: 'lsj', width: 80, hidden: true,
                    formatter: function (val) {
                        return val.toFixed(4);
                    } },
                { label: '单位', name: 'zxdwmc', width: 50, align: 'center' },
                { label: '规格', name: 'gg', width: 100, align: 'left' },
                { label: '品牌', name: 'brand', width: 150, align: 'left' },
                { label: '生产厂家', name: 'sccj', width: 150, align: 'left' },
                {
                    label: '是否零库存', name: 'sflkc', width: 70, align: 'center',
                    formatter: function (cellvalue) { return cellvalue === "1" ? "是" : "否"; }
                },
                {
                    label: '是否复用', name: 'sffy', width: 60, align: 'center',
                    formatter: function (cellvalue) { return cellvalue === "1" ? "是" : "否"; }
                },
                {
                    label: '是否跟台', name: 'sfgt', width: 55, align: 'center',
                    formatter: function (cellvalue) { return cellvalue === "1" ? "是" : "否"; }
                },
                { label: "productId", name: "productId", hidden: true, key: true }
            ],
            pager: "#gridPager",
            sortname: 'wzmc asc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: $("#form1").formSerialize()
            }).trigger('reloadGrid');
        });
       $("#btn_print").click(function () {
           window.open('@reportUrl' + "?tempCode=1266" + "&systemCode=" + '@reportSystemCode' + "&hospitalCode=" + '@ViewBag.OrganizeId' + "&OrganizeId=@ViewBag.OrganizeId&warehouseId=@Constants.CurrentKf.currentKfId" +
               "&keyWord=" + ($("#keyWord").val() === "" ? "" : $("#keyWord").val()) +
               "&lbId=" + ($("#lb option:selected").val() === "" ? "" : $("#lb option:selected").val()) +
               "&kzbz=" + ($("#kzbz option:selected").val() === "" ? "" : $("#kzbz option:selected").val()) +
               "&wzzt=" + ($("#wzzt option:selected").val() === "" ? "" : $("#wzzt option:selected").val())
               );
        });
    }

    //类别
    function initialddlYPLBList() {
        $("#lb").bindSelect({
            url: "/ProductManage/ProductType/GetPatientTreeSelectJson"
        });
    }
</script>